﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using System.Web.Http.Results;
using WebApi.Framework;

namespace WebApi.Controllers
{
    [RequestAuthorize]
    public class HomeController : ApiController
    {
        [HttpGet]
        public HttpResponseMessage Test()
        {
            return new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent("Test", Encoding.UTF8, "application/json")
            };
        }

        [HttpGet]
        public HttpResponseMessage Test2()
        {
            var result = new { name = "bruke", id = 1 };
            return new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(result), Encoding.UTF8, "application/json")
            };
        }

        /// <summary>
        /// 请求数据库
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public HttpResponseMessage Test3()
        {
            var result = new { name = "我的名字叫bruke", id = 1 };
            return new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(result), Encoding.UTF8, "application/json")
            };
        }

    }
}
